package eco2automotive.gui.components;
  import java.awt.*;
  import javax.swing.*; 
/** Create a new progress bar.
  * @version 1.0
  * @autor Fco. Javier Sánchez Esparza
 */
public class Panel_PROGRESS extends JPanel{
    
  private  JProgressBar current;
  private JLabel label;
  private  int num=0;
  private  int max=0;
  /**
   * Set the max value for the progress.
   * @param max
   */
  public Panel_PROGRESS(int max){    
    this.max=max;
    label=new JLabel("Progress...");
    current = new JProgressBar(0, max);    
    current.setValue(0);
    current.setStringPainted(true);
    this.setLayout(new FlowLayout(FlowLayout.LEFT));
    this.add(label);
    this.add(current);    
        }    
/**
 * Advance the progress bar
 */
public void advance() {
  if (num <= max) {
  current.setValue(num);    
  num += 1; }
  else restart();  
}
/**
 * Set a label to display
 * @param label
 */
public void updateLabel(String label){this.label.setText(label);}
/**
 * Restart the proccess
 */
public void restart(){this.num=0;}
}
